package com.example.springboottest.big3;

import org.springframework.beans.factory.annotation.Value;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 请求路径是 curl http://localhost:9090/first/  不要忘写后面的first/
 */
public class FirstServlet extends HttpServlet {
    @Value("${spring.user.name}")
    private String greeting;

    @Override
    public void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        log("----FirstServlet---");
        resp.setContentType("text/html");
        resp.setCharacterEncoding("utf-8");
        PrintWriter out = resp.getWriter();
        out.println("为Spring Boot添加的第一个Servlet，信息：欢迎您\t" + greeting);
    }
}
